package com.test.cordova.observer;

/**
 * 网络状态改变之被观察者
 */

public class NetStateObservable extends Observable<NetObserver> {

    private static  NetStateObservable instance = null;
    private NetStateObservable(){}
    public synchronized static NetStateObservable getInstance(){
        if (instance == null) {
            instance = new NetStateObservable();
        }
        return instance;
    }

    @Override
    public void notifyObservers(Object... objects) {
        if (objects==null) throw new NullPointerException();
        synchronized (observeList) {
            for (NetObserver cls: observeList) {
                this.notifyObserver(cls,objects);
            }
        }
    }
    @Override
    public void notifyObserver(NetObserver cls, Object... objects) {
        if (cls == null) throw new NullPointerException();
        cls.netStateChange(objects);
    }

}
